﻿<!DOCTYPE html>
<html>
<head>
    <title>督查概况</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>
    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>
</head>
<body>
<style>
    .layui-btn{height: 30px;line-height: 30px;}
    .new_main{
        margin:20px;
    }
    .nav-tabs{
        margin-bottom:20px;
    }
    /*.nav-tabs{*/
    /*    margin:20px 20px;*/
    /*    border-bottom:0px;*/
    /*}*/
    /*.nav-tabs li{*/
    /*    margin-right:40px;*/
    /*}*/
    /*.nav-tabs .active{*/
    /*    background-color: #005ec5;*/
    /*    border-radius:8px;*/
    /*}*/
    /*.nav-tabs .active a{*/
    /*    background-color: #005ec5!important;*/
    /*    border:0px!important;*/
    /*    border-radius:8px;*/
    /*    color: #FFFFFF!important;*/
    /*}*/
</style>

<div class="new_main">
    <div class="tabbable" id="tabs-653539">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#balance" data-toggle="tab">督查概况</a>
            </li>
            <li>
                <a href="#integral" data-toggle="tab">整改完成情况</a>
            </li>
        </ul>

        <div class="tab-content" id="changes">
            <div class="tab-pane active" id="balance">

                <!--督查概况-->
                <form class="layui-form layui-form-pane form-horizontal" action=""  name="overseerForm">

                    <div class="layui-form-item layui-col-md12 "  >
                        <label class="layui-form-label">逾期原因</label>
                        <div class="layui-input-block" >
                            <textarea placeholder="备注" class="layui-textarea" name="cause">{$detail.cause}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item layui-col-md12"  >
                        <label class="layui-form-label">督办流程</label>
                        <div class="input-group col-xs-4" style="float: left">
                            <select name="overseer_course">
                                <option value="0">请选择</option>
                                {volist name="overseerArray" id="vo"}
                                <option {if condition="$detail.overseer_course eq $vo"} selected {/if} value="{$vo}">{$vo}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item layui-col-md12"  >
                        <label class="layui-form-label">县级领导</label>
                        <div class="input-group" style="float: left">
                            <div id="leader" class="demo-transfer"></div>
                        </div>
                    </div>

                    <div class="layui-form-item layui-col-md12"  >
                        <label class="layui-form-label">整改单位</label>
                        <div class="input-group " style="float: left">
                            <div id="change" class="demo-transfer"></div>
                        </div>
                    </div>

                    <div class="layui-form-item layui-col-md12"  >
                        <label class="layui-form-label">整改时间</label>
                        <div class="input-group col-xs-4" style="float: left">
                            <input type="text" name="change_time" placeholder="限期整改时间" class="layui-input time" value="{$detail.change_time}"  >
                        </div>
                    </div>

                    <div class="layui-form-item layui-col-md12"  >
                        <label class="layui-form-label">移除曝光台</label>
                        <div class="input-group col-xs-4" style="float: left">
                            <input type="radio" name="exposureAuto" value="0" title="不移除" {if condition="$detail['exposureAuto'] eq 0"} checked {/if} >
                            <input type="radio" name="exposureAuto" value="1" title="移除" {if condition="$detail['exposureAuto'] eq 1"} checked {/if}>
                        </div>
                    </div>

                    <input type="hidden" name="id" value="{$detail.id}">

                    <div class="layui-form-item layui-col-md12">
                        <label class="layui-form-label">操作</label>
                        <div class="input-group col-xs-10" style="float: left;margin:4px 10px">
                            <a class="layui-btn overseerSave">更新</a>
                        </div>
                    </div>
                </form>

            </div>
            <div class="tab-pane" id="integral">
                <script type="text/html" id="toolbarDemo">
                    <div class="layui-btn-container">
                        <a class="layui-btn-sm layui-btn" lay-event="add">添加</a>
                        <a class="layui-btn-sm layui-btn layui-btn-danger" lay-event="getCheckLength">批量删除</a>
                    </div>
                </script>
                <table class="layui-hide" id="demo" lay-filter="demo"></table>
                <script type="text/html" id="switchTpl">
                    <!--启用禁用操作-->
                    <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="sexDemo" {{ d.status == 1 ? 'checked' : '' }}>
                </script>
                <script type="text/html" id="barDemo">
                    <button class="layui-btn layui-btn-sm" lay-event="detail">查看详情</button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</button>
                </script>
            </div>
        </div>

    </div>
</div>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<!--弹框js-->
<script src="/static/js/yii.js"></script>
<script>
    layui.use(['form','jquery','layer','laydate','table','upload','transfer'], function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer,upload = layui.upload;;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格
        var transfer = layui.transfer;

        $(".overseerSave").click(function (){
            var overseerForm = $("form[name='overseerForm']").serializeArray();
            var leader = transfer.getData('leader');
            var leader_v = eachvalue(leader);
            var change = transfer.getData('change');
            var change_v = eachvalue(change);
            overseerForm.push({name: "leader", value: leader_v});
            overseerForm.push({name: "change_unit", value: change_v});
            $.ajax({
                type:'post',
                url:"{:URL('project/Overseer/save')}",
                data:overseerForm,
                dataType:'JSON',
                success:function (res) {
                    if(res.code!=0){
                        layer.alert(res.msg);
                    }else{
                        location.reload()
                    }
                },
                error:function (res) {
                }
            });
        });

        function eachvalue(data){
            var newvalue = '';
            $.each(data,function (index,value) {
                newvalue+=value.title+";";
            });
            return newvalue;
        };

        //日期范围
        //同时绑定多个
        lay('.time').each(function(){
            laydate.render({
                elem: this
                ,trigger: 'click'
                ,type: 'date'
                ,theme: 'molv'
            });
        });

        var url = "{:URL('project/Overseer/index')}";
        var detail = "{:URL('project/Overseer/detail')}";

        //搜索操作
        $('.serach_btn').click(function () {
            var data=$("form[name='searchForm']").serializeArray();
            var dataVal = {};
            $.each(data, function(i, item){
                dataVal[item.name] = item.value;
            });
            var where = dataVal;
            search(table,url,where)
        });

        //列表
        var data=$("form[name='searchForm']").serializeArray();
        var pro_id = $("input[name='id']").val();
        var dataVal = {type:'list',pro_id:pro_id};
        $.each(data, function(i, item){
            dataVal[item.name] = item.value;
        });
        var where = dataVal;

        var title = "权限列表";
        var cols = [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'sumbitName', title: '提交人', align:'center'}
            ,{field: 'content', title: '内容', align:'center'}
            ,{field: 'addtime', title: '提交时间', align:'center'}
            ,{field: 'statusName', title: '状态', align:'center'}
            ,{fixed: 'right',title: '操作', width:200, align:'center', toolbar: '#barDemo'}
        ]];
        showlist(table,url,where,title,cols,0,10,'#demo','#toolbarDemo');
        $(".layui-laypage-skip").find("input").val(3 );
        $(".layui-laypage-btn").click();


        //监听行工具事件
        table.on('tool(demo)', function(obj) {
            var id = obj.data.id;
            switch (obj.event) {
                case 'del':
                    layer.confirm('是否确定操作?', function (index) {
                        let url = "{:URL('project/Overseer/del')}";
                        let where = {id: id};
                        publicDel(table, url, where, obj, index, 1);
                    });
                    break;
                case 'detail':
                    var showUrl = detail+"?id="+id;
                    showView(showUrl,"详情");
                    break;
                case 'edit':
                    let editView = "{:URL('project/Overseer/editView')}";
                    var showUrl = editView+"?id="+id;
                    showView(showUrl,"编辑");
                    break;
            }
        })


        function showView(showUrl,type){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['80%','90%'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: type,
                content:showUrl,
                btn:['确认','关闭'],
                yes: function (index,layero) {
                    var body = layer.getChildFrame('body', index);
                    var data = body.find("form[name='saveForm']").serializeArray();
                    // data.push({name: "plan_id", value: plan_id});
                    $.ajax({
                        type: "post",
                        url: "{:URL('project/Overseer/addOverseer')}",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            if(data.code==0){
                                layer.close(index);
                                table.reload("demo");
                            }else{
                                layer.alert(data.msg);
                            }

                        }
                    });
                },
            });
        }


        //头工具栏事件
        table.on('toolbar(demo)', function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'add':
                    var showUrl = "{:URL('project/Overseer/detail')}?pro_id="+pro_id;
                    showView(showUrl,"添加");
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    if(id.length==0){
                        layer.alert("请选择需操作的数据");return;
                    }

                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('project/Overseer/del')}";
                        let where = {id:id};
                        publicDel(table,url,where,obj,index,1);
                    });
                    break;
            }
        });


        //责任单位
        var duty_unit = {$duty_unit};
        var account= {$account};
        //县级领导
        transfer.render({
            elem: '#leader'
            ,id:'leader'
            ,data: account
            ,title: ['全选', '全选']
            ,showSearch: true
            ,height:200
            ,value:{$leader_k}
        })

        //整改单位
        transfer.render({
            elem: '#change'
            ,id:'change'
            ,data: duty_unit
            ,title: ['全选', '全选']
            ,showSearch: true
            ,height:200
            ,value:{$change_k}
        })





        layui.form.render('select');
    });
</script>
</body>
</html>
